<%--
  Created by IntelliJ IDEA.
  User: LJJ
  Date: 2023/3/8
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8"/>
    <title>废仓处理</title>

    <link href="css/all.css" rel="stylesheet" type="text/css">
    <link href="js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">

</head>
<body>

<div class="div_find">

    <p><label class="find_labela">仓库名：</label><input class="find_input" id="name">
        <%--        <option>全部</option>--%>
        <%--        <option>十一届</option>--%>
        <%--        <option>十二届</option>--%>
        <%--        <option>十三届</option>--%>
        <%--        <option>十四届</option>--%>
        <%--        <option>十五届</option>--%>

    </input><label class="find_labela">地址：</label><input class="find_input" id="address">
        <%--        <option>全部</option>--%>
        <%--        <option>立案提案</option>--%>


    </input>

        <input type="button" value="搜索一下" onclick="showWarehouse()" class="find_but" id="but_close">
        <input type="button" value="重置" onclick="clean()" class="find_but" id="but_close01"></p></div>
<p class="p_but">

    <i class="down_i"></i><a href="#" class="add_a">导出</a>
    <i class="print_i"></i><a href="#" class="add_a">打印</a>
</p>

<p>
<table id="table" class="table" style="margin: 0 auto">
</table>
</p>

<script src="js/jquery/jQuery-2.2.0.min.js"></script>
<script src="js/bstable/js/bootstrap.min.js"></script>
<script src="js/bstable/js/bootstrap-table.js"></script>
<script src="js/bstable/js/bootstrap-table-zh-CN.min.js"></script>
<script src="js/date/js/laydate.js"></script>

<script>
    showWarehouse();

    function showWarehouse() {
        $.ajax({
            url: "queryDeletedWarehouse.do",
            type: "POST",
            data: {
                "name": $("#name").val(),
                "address": $("#address").val()
            },
            dataType: "json",
            success: function (data) {
                var str = "";
                str += "<tr><th>编号</th><th>仓库名</th><th>电话</th><th>地址</th><th>操作</th></tr>"
                for (var i = 0; i < data.length; i++) {
                    str += "<tr>"
                    str += "<td>" + data[i].id + "</td>"
                    str += "<td>" + data[i].name + "</td>"
                    str += "<td>" + data[i].phone + "</td>"
                    str += "<td>" + data[i].address + "</td>"
                    str += "<td><a href='#' onclick='resumeWarehouse(" + data[i].id + ")' >恢复</a><a href='#' onclick='writeOff(" + data[i].id + ")'>注销</a></td>"
                }
                $("#table").html(str)

            }

        })
    }

    function clean() {
        $("#name").val("");
        $("#address").val("");
        showWarehouse();
    }

    function resumeWarehouse(id) {
        $.ajax({
            url: "resumeWarehouse.do",
            type: "post",
            data: {
                "id": id
            },
            dataType: "json",
            success: function (data) {
                alert(data.msg)
                if (data.code == "1") {
                    window.location.reload()
                }
            }
        })
    }

    function writeOff(id) {
        $.ajax({
            url: "writeOff.do",
            type: "post",
            data: {
                "id": id
            },
            dataType: "json",
            success: function (data) {
                alert(data.msg)
                if (data.code == "1") {
                    window.location.reload()
                }
            }
        })
    }

</script>


</body>
</html>

